local skynet = require "skynet"
local filelog = require "filelog"
local msghelper = require "recordsvrhelper"
local httpc = require "http.httpc"
local configdao = require "configdao"
local base = require "base"

local RecordsvrCMD = {}

function RecordsvrCMD.process(session, source, event, ...)
	local f = RecordsvrCMD[event] 
	if f == nil then
		filelog.sys_error("recordsvrd RecordsvrCMD.process invalid event:"..event)
		return nil
	end
	f(...)	 
end

function RecordsvrCMD.start(...)
	skynet.retpack(true)
	httpc.dns()
	local recordmqsvrs = configdao.get_svrs("recordmqsvrs")
	for mqsvr_id, mqsvr in pairs(recordmqsvrs) do
		skynet.fork(function()
			msghelper:readmq(mqsvr_id, mqsvr)
		end)
	end
 
end

function RecordsvrCMD.reload(...)
	base.skynet_retpack(1)
	filelog.sys_error("RecordsvrCMD.reload start")

	configdao.reload()
	
	filelog.sys_error("RecordsvrCMD.reload end")
end

return RecordsvrCMD
